<template>
  <div class="mui-numbox" data-numbox-min='1' :data-numbox-max='max'>
    <button class="mui-btn mui-btn-numbox-minus" type="button">-</button>
    <input id="test" class="mui-input-numbox" type="number" value="1" ref='nobox' @change="changed" />
    <button class="mui-btn mui-btn-numbox-plus" type="button">+</button>
  </div>
</template>


<script>
import mui from '../../../lib/mui/js/mui'
export default {
  data() {
    return {};
  },
  methods: {
    changed(){
      const val = this.$refs.nobox.value
      this.$emit('func', parseInt(val))
    }
  },
  mounted(){
    // 当组件挂载到页面中，去初始化 数字框
    mui('.mui-numbox').numbox();
  },
  props:['max'],
  watch: {
    // 监听单个的虚拟数据
    max: function(newval,oldval){
      mui('.mui-numbox').numbox().setOption("max", newval)
    }
  }
  
};
</script>

<style lang="scss" scoped>

</style>